package com.hongkzh.www.adv.controller;

import com.hongkzh.www.adv.service.AdvService;
import com.hongkzh.www.conmon.ReqResponse;
import com.hongkzh.www.swagger.annotation.*;
import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;

import java.util.List;

/**
 * @author martins
 */
@Api(tag = "enterpriseAdv", description = "企业广告")
public class EnterpriseAdvController extends Controller {
    static AdvService advService=new AdvService();



    @ApiOperation(url = "/v1/enterpriseAdv/getEnterpriseCategoryList", tag = "enterpriseAdv", httpMethod = "post",description = "获取企业广告分类列表")
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{   label 标题   id 类别id }"),
                    @ResponseHeader(name="msg",description = "失败原因") })
    })
    public void getEnterpriseCategoryList(){
        ReqResponse< List<Record>> r=new ReqResponse();
        List<Record>  record= advService.getEnterpriseCategoryList();
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/enterpriseAdv/getEnterpriseHotAdvTypeList", tag = "enterpriseAdv", httpMethod = "post",description = "获取企业广告热度类型列表")
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{   title 标题 subtitle 副标题 id  }"),
                    @ResponseHeader(name="msg",description = "失败原因") })
    })
    public void getEnterpriseHotAdvTypeList(){
        ReqResponse< List<Record>> r=new ReqResponse();
         List<Record>  record= advService.getEnterpriseHotAdvTypeList();
        r.setData(record);
        renderJson(r);
    }
    @ApiOperation(url = "/v1/enterpriseAdv/getEnterpriseHotAdvList", tag = "enterpriseAdv", httpMethod = "post",description = "获取企业广告热度列表")
    @Params({
            @Param(name = "id", description = "企业广告热度类型id", required = true, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "{ coverImgSrc 图片地址   imgRank 图片排序 title 标题   praiseCount 点赞总数 shareCount 分享总数 costCount 消费总数 integralCount 总积分数 lastCount 剩余积分 percentage 百分比 uid 用户id  uName 用户名称 headImg  用户头像   }"),
                    @ResponseHeader(name="msg",description = "失败原因") })
    })
    public void getEnterpriseHotAdvList(){
        String id=getPara("id");
        ReqResponse< List<Record>> r=new ReqResponse();
        List<Record>  record= advService.getEnterpriseHotAdvList(id);
        r.setData(record);
        renderJson(r);
    }

    @ApiOperation(url = "/v1/enterpriseAdv/getEnterpriseCategoryAdvList", tag = "enterpriseAdv", httpMethod = "post",description = "获取企业广告分类分页列表")
    @Params({
            @Param(name = "id", description = "分类id", required = true, dataType = "string"),
            @Param(name = "pageNumber", description = "页码", required = true, dataType = "string"),
            @Param(name = "sortId", description = "排序字段 默认排序 rank  最多浏览 play_count  最新上传 create_date ", required = false, dataType = "string"),
            @Param(name = "sortValue", description = "排序值 asc 升 desc 降 ", required = false, dataType = "string")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="成功",responseHeaders={
                    @ResponseHeader(name="code",description = " 0成功 1失败"),
                    @ResponseHeader(name="data",description = "totalRow 总行数  pageNumber第几页 firstPage 是否第一页 lastPage 是否最后一页 totalPage 总页数 pageSize每页条数  list[{ coverImgSrc 图片地址 coverLink 图片链接  imgSrc 视频地址 ,imgLinks 视频链接 imgRank 图片排序 title 标题 imgNote 副标题   headImg 头像   uid 用户id  uName 用户名 shareCount分享总数  praiseCount点赞总数 }]"),
                    @ResponseHeader(name="msg",description = "失败原因") })

    })
    public void getEnterpriseCategoryAdvList(){
        String cid=getPara("id");
        int pageNumber=getParaToInt("pageNumber");
        String sortId=getPara("sortId");
        String sortValue=getPara("sortValue");
        ReqResponse<Page<Record>> r=new ReqResponse();
        Page<Record> record= advService.getEnterpriseCategoryAdvList(cid,pageNumber,sortId,sortValue);
        r.setData(record);
        renderJson(r);
    }





}
